﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
<script type="text/javascript">
    function disablesave() {
        $(".btn-warn-f").attr("disabled", "disabled");
    }
    function enablesave(str) {
        $(".btn-warn-f").removeAttr("disabled", "disabled");
    }
    function saveOption() {
        disablesave();
        var len = $('.wrapR-c-box-b-right ul input').size();
        if (len <= 0) {
            messageAlert('请添加需要在线提交的数据库！');
            enablesave();
            return;
        }
        var jsondata = [];
        $('.wrapR-c-box-b-right ul input').each(function (index) {
            var dataobj = {
                "DbCode": $(this).val(),
                "DbName": $.trim($(this).parent().text()),
                "Name": "在线提交",
                "SortNum": len - index,
                "Flag": "1"
            }
            jsondata.push(dataobj);

        })
        var dataold = { "list": jsondata };
        $.ajax({
            type: "POST",
            url: "@Html.Raw(Url.Action("SaveOptionDB", "Admin_Submit"))",
            contentType: "application/json",
            data: JSON.stringify(dataold),
            success: function (msg) {
                if (msg == "True") {
                    messageAlert("操作成功！");

                }
                else {
                    messageAlert("操作失败！");
                }
                enablesave();
            },
            error: function (e)
            { enablesave(); }
        })

    }
</script>
<div class="wrapR-c wrapR-c2" style="padding-top: 50px; padding-bottom: 20px">
    <div class="clearfix posr wrapR-c2-in">
        <div class="wrapR-c-box wrapR-c-l fl posr" style="overflow-y: visible">
            <div class="wrapR-c-box-t">待提交数据库</div>
            <div class="wrapR-c-box-b-left" style="overflow-y: scroll; height: 380px">
                <ul>
                    @{
                        if (ViewBag.DBList != null)
                        {
                            foreach (SYS_CMS_DATABASE item in ViewBag.DBList)
                            {
                                if (item.SearchType == ((int)SearchType.TPI) && item.DatabaseType != 2)
                                {
                        <li class="f-ct">
                            <label class="f-label block">
                                <input type="checkbox" class="f-checkboxL" onclick="leftcheck(this)" value='@item.DatabaseCode' />@item.DatabaseName</label>

                        </li>
                                }
                            }
                        }

                    }

                </ul>
                <div class="f-ct wrapR-c-box-footer posa">
                    <label class="f-label ml10">
                        <input type="checkbox" class="f-checkbox-left" onclick="leftCheckAll(this)" />全选</label>
                </div>
            </div>

        </div>
        <div class="wrapR-c-m tc posa">
            <a class="iconfont-s iconfont-right-triangle-s" onclick="rightMove('.wrapR-c-box-b-left','.wrapR-c-box-b-right')"></a>

        </div>
        <div class="fr posr">
            <div class='wrapR-c-box wrapR-c-r wrapR-c-r-l' style="overflow-y: visible">
                <div class="wrapR-c-box-t">已提交数据库</div>
                <div class="wrapR-c-box-b-right" style="overflow-y: scroll; height: 380px">
                    <ul class="ulfield">
                        @if (ViewBag.SubmitList != null)//修改时加载已经设置的字段
                        {
                            foreach (SYS_CMS_OPTION item in ViewBag.SubmitList)
                            {
                            <li class="f-ct">
                                <label class="f-label block right">
                                    <input type="checkbox" class="f-checkboxR" value='@item.DbCode' />@item.DbName</label>

                            </li>
                            }
                        }
                    </ul>
                    <div class="f-ct wrapR-c-box-footer posa clearfix">
                        <label class="f-label ml10 fl">
                            <input type="checkbox" class="f-checkbox-right" onclick="rightCheckAll(this)">全选</label>
                        <a class="btn btn-s btn-warn-f fr deleteright" onclick="deleteright()">删除</a>
                    </div>
                </div>
            </div>

            <div class="wrapR-c-r-r form-h posa" style="top: 10px">
                <div style="padding-bottom: 50px">
                   <a title="移至最顶部" onclick=" movefirst(this)" class="iconfont-s iconfont-upest-s"></a>
                    <br />
                    <a title="上移" onclick="moveablove(this)" class="iconfont-s iconfont-up-s"></a>
                    <br />
                    <a title="下移" onclick="movedown(this)" class="iconfont-s iconfont-down-s"></a>
                    <br />
                    <a title="移至最底部" onclick="movelast(this)" class="iconfont-s iconfont-downest-s"></a>
                </div>

            </div>
        </div>
    </div>
    <div class="tc mt30">

        <button class="btn btn-m btn-submit btn-warn-f" onclick="saveOption()">保存</button>
    </div>
</div>
<!-- wrapREnd -->
